home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / oocs / frmserve.frm < prev    next >
Text File  |  1999-09-06  |  3KB  |  120 lines

  1. VERSION 5.00
  2. Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
  3. Begin VB.Form frmServer 
  4.    BorderStyle     =   4  'Fixed ToolWindow
  5.    Caption         =   "Server"
  6.    ClientHeight    =   570
  7.    ClientLeft      =   8010
  8.    ClientTop       =   5190
  9.    ClientWidth     =   4680
  10.    Icon            =   "frmServer.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   570
  15.    ScaleWidth      =   4680
  16.    ShowInTaskbar   =   0   'False
  17.    Begin VB.CommandButton cmdExit 
  18.       Caption         =   "&Exit"
  19.       Height          =   375
  20.       Left            =   3720
  21.       TabIndex        =   0
  22.       Top             =   120
  23.       Width           =   855
  24.    End
  25.    Begin MSWinsockLib.Winsock tcpServer 
  26.       Left            =   4080
  27.       Top             =   2160
  28.       _ExtentX        =   741
  29.       _ExtentY        =   741
  30.       _Version        =   393216
  31.    End
  32.    Begin VB.Label lblCReq 
  33.       BorderStyle     =   1  'Fixed Single
  34.       Height          =   255
  35.       Left            =   120
  36.       TabIndex        =   1
  37.       Top             =   160
  38.       Width           =   3495
  39.    End
  40. End
  41. Attribute VB_Name = "frmServer"
  42. Attribute VB_GlobalNameSpace = False
  43. Attribute VB_Creatable = False
  44. Attribute VB_PredeclaredId = True
  45. Attribute VB_Exposed = False
  46. Option Explicit
  47.  
  48. Private WithEvents RemoteServer As cServerActions
  49. Attribute RemoteServer.VB_VarHelpID = -1
  50.  
  51.  
  52.  
  53. Private Sub RemoteServer_ConnectionClosed()
  54.     Form_Load      ' reload the form
  55.     
  56.     Set RemoteServer = Nothing
  57.     Set Server_ = Nothing
  58. End Sub
  59.  
  60. Private Sub RemoteServer_RequestedID(Accepted As Boolean)
  61.     
  62.     If Accepted Then
  63.        'Set the connection variable
  64.        bInConnection = True
  65.        SendData "Accepted,"
  66.        StatusReport "Connection Made"
  67.        Exit Sub
  68.     End If
  69.     ' notify client there was a connection error
  70.     SendData "Request_Error, There was an error with the RequestID"
  71.     
  72. End Sub
  73.  
  74.  
  75. Private Sub tcpServer_Close()
  76.     Server_.Closed tcpServer
  77.     StatusReport "Connection Terminated"
  78. End Sub
  79.  
  80.  
  81. Private Sub tcpServer_ConnectionRequest(ByVal requestID As Long)
  82.     If bInConnection Then Exit Sub      'if connected continue, don't accept
  83.     
  84.     ' re create and reference the objects, since they were
  85.     ' destroyed earlier when the connection was terminated
  86.     Set Server_ = New cServerActions
  87.     Set RemoteServer = Server_
  88.     ' send in the connection request
  89.     Server_.ConnectReq requestID, tcpServer
  90.     
  91. End Sub
  92.  
  93. Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
  94.     Dim sIncoming As String
  95.     tcpServer.GetData sIncoming
  96.   
  97.     '--- send the data to be evaluated
  98.     Server_.HandleIncomingData sIncoming, tcpServer, frmServer
  99.   
  100. End Sub
  101.  
  102. Private Sub cmdExit_Click()
  103.     Unload Me
  104. End Sub
  105.  
  106. Private Sub Form_Load()
  107.     On Error GoTo GetOut
  108.     Server_.InitTCP 333, tcpServer   ' initialze winsock to listen
  109.     bInConnection = False
  110.     
  111. GetOut:
  112.     Exit Sub
  113. End Sub
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.